package common.filter;



import org.springframework.stereotype.Component;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import java.io.IOException;

/**
 * @Author: 郑国荣
 * @Date: 2024-03-05-18:18
 * @Description:
 */

@Component
@WebFilter(filterName = "UserServiceFilter", urlPatterns = {"/user/*"})
public class UserServiceFilter extends ServiceFilter {

//    String[] excludePatterns = new String[]{
//            "/doc.html",
//            "/doc.html*",
//            "/webjars",
//            "/webjars/**",
//            "/img.icons/**",
//            "/swagger-resources",
//            "/swagger-resources/**",
//            "/**/v2/api-docs",
//            "/favicon.ico",
//            "/swagger-ui.html"
//    };


    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {

        System.out.println("进入过滤器========");
        super.doFilter(servletRequest, servletResponse, filterChain);
        // excludePatterns
//        boolean isExcluded = false;
//        for (String excludePattern : excludePatterns) {
//            if (path.contains(excludePattern)) {
//                System.out.println("swagger请求");
////                isExcluded = true;
//                break;
//            }
//        }
//        if(!isExcluded && (gateway == null || !gateway.equals(TokenConstant.FILTER_KEY_VALUE))){
//            System.out.println("非法请求");
//            HttpServletResponse response = (HttpServletResponse) servletResponse;
//            response.sendError(HttpCodeEnum.CROSS_GATEWAY_REQUEST.getCode(), "非法请求");
//            return;
//        }
//        filterChain.doFilter(servletRequest, servletResponse);
    }

}
